home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / gamtlk11.zip / source.zip / CARIBBEAN POKER / PROFILE.CPP < prev    next >
C/C++ Source or Header  |  1999-12-06  |  3KB  |  75 lines

  1. //
  2. // File: Profile.CPP
  3. //
  4. // Handles the game profile
  5. //
  6. #include <string.h>
  7. #include "CPoker.HPP"
  8.  
  9. #define  PRFKEY_XPOS    "XPos"
  10. #define  PRFKEY_YPOS    "YPos"
  11. #define  PRFKEY_XSIZE   "XSize"
  12. #define  PRFKEY_YSIZE   "YSize"
  13. #define  PRFKEY_WAGER   "Wager"
  14. #define  PRFKEY_PREFS   "Prefs"
  15. #define  PRFKEY_JACKPOT "Jackpot"
  16. #define  PRFKEY_BANK    "Bank"
  17. #define  PROFILE_APPNAME   "Caribbean Poker"
  18.  
  19. //
  20. // PROFILE::PROFILE(const char *FileName)
  21. //
  22. // Default constructor for the profile.
  23. //
  24. PROFILE::PROFILE(const char *FileName): IProfile::IProfile(FileName),
  25.    Position(54,54), Size(655,655), Preferences(0), Wager(MIN_WAGER), Jackpot(DEF_JACKPOT),
  26.    Bank(DEF_BANK), Background(IColor(IColor::kDarkRed)), Foreground(IColor(IColor::kWhite)), Speed(200)
  27. {
  28.    // Save the file name
  29.    strncpy(fileName, FileName, sizeof(fileName));
  30.  
  31.    // Try loading values
  32.    setDefaultApplicationName(PROFILE_APPNAME);
  33.    try
  34.    {
  35.       Position.setX(elementWithKey(PRFKEY_XPOS).asUnsigned());
  36.       Position.setY(elementWithKey(PRFKEY_YPOS).asUnsigned());
  37.       Size.setWidth(elementWithKey(PRFKEY_XSIZE).asUnsigned());
  38.       Size.setHeight(elementWithKey(PRFKEY_YSIZE).asUnsigned());
  39.       Preferences=elementWithKey(PRFKEY_PREFS).asUnsigned();
  40.       Wager=elementWithKey(PRFKEY_WAGER).asUnsigned();
  41.       Jackpot=elementWithKey(PRFKEY_JACKPOT).asDouble();
  42.       Bank=elementWithKey(PRFKEY_BANK).asDouble();
  43.    } catch(...) {};
  44. }
  45.  
  46. //
  47. // PROFILE::~PROFILE()
  48. //
  49. // Main destructor for the profile class
  50. //
  51. PROFILE::~PROFILE()
  52. {
  53.    addOrReplaceElementWithKey(PRFKEY_XPOS, IString(Position.x()));
  54.    addOrReplaceElementWithKey(PRFKEY_YPOS, IString(Position.y()));
  55.    addOrReplaceElementWithKey(PRFKEY_XSIZE, IString(Size.width()));
  56.    addOrReplaceElementWithKey(PRFKEY_YSIZE, IString(Size.height()));
  57.    addOrReplaceElementWithKey(PRFKEY_PREFS, IString(Preferences));
  58.    addOrReplaceElementWithKey(PRFKEY_WAGER, IString(Wager));
  59.    addOrReplaceElementWithKey(PRFKEY_JACKPOT, IString(Jackpot));
  60.    addOrReplaceElementWithKey(PRFKEY_BANK, IString(Bank));
  61. }
  62.  
  63. //
  64. // void CPOKER::saveProfile()
  65. //
  66. // Saves a main window's data into its profile.  Does NOT write out the profile itself.
  67. //
  68. void CPOKER::saveProfile()
  69. {
  70.    Profile.Position=position();
  71.    Profile.Size=size();
  72.    if(autoButton.isSelected()) Profile.Preferences|=PROFILE::AUTO_PROGRESSIVE;
  73.       else Profile.Preferences&=~PROFILE::AUTO_PROGRESSIVE;
  74.    Profile.Wager=wager.value();
  75. }